<?php

namespace app\backend\controller;

use app\backend\library\DataController;
use app\backend\validator\UpdUserValidator;
use app\common\model\User as UserModel;

class User extends DataController
{
    protected $mdl = UserModel::class;

    protected $excludeMainFields = ['encrypt_password'];

    protected $allowSortFields = [
        'id',
        'status',
        'login_time',
        'created_at',
        'register_time',
        'loginnum',
        'failnum',
    ];

    protected $allowSearchFields = [
        'id',
        'email',
        'status',
        'login_ip',
        'created_at',
        'register_time',
        'login_time',
    ];

    protected function _saveBeforeHook(&$params)
    {
        if(!empty($params['id'])) {
            $this->validate($params, UpdUserValidator::class);
        }
    }
}